0% found this document useful (0 votes)
14 views3 pages

ASSIGNMENT

The document contains 12 programming problems involving concepts like loops, conditional statements, functions, patterns, switch case in C language. The problems include correcting errors in code snippets, writing programs to find sum of natural numbers, convert Celsius to Fahrenheit, print patterns like pyramid, half pyramid and Floyd's triangle. Another problem involves writing a program to take food order and display total charges using switch case.

Uploaded by

rai662899
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

ASSIGNMENT

The document contains 12 programming problems involving concepts like loops, conditional statements, functions, patterns, switch case in C language. The problems include correcting errors in code snippets, writing programs to find sum of natural numbers, convert Celsius to Fahrenheit, print patterns like pyramid, half pyramid and Floyd's triangle. Another problem involves writing a program to take food order and display total charges using switch case.

Uploaded by

rai662899
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT

PREDICT THE ERROR (SYNTACTICAL AS WELL AS LOGICAL (IF ANY)) OF THE FOLLOWING C CODES AND
ALSO FIND THE OUTPUT AFTER CORRECTION (IF ANY):

1. #include<stdio.h>
int main()
{
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}

2. #include <stdio.h>
int main()
{
int c = 5, no = 10;
do
{
no /= c;
}while(c--)
printf ("%dn" no);
return 0;
}

3. # include <stdio.h>
int main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i);
{
case 0;
i += 5;
case 1;
i += 2;
case 5;
i += 5;
default;
i += 4;
break;
}
printf("%d", i);
}
return 0;
}

4. #include <stdio.h>
int main()
{
int i;
for (i = 1; i != 10; i = 2)
printf(" C Programming ");
return 0;
}

5. #include<stdio.h>
int main()
{
int i =- 5;
while (i <= 5)
{
if (i >= 0)
break;
else
{
i++;
continue;
}
printf("C Programming");
}
return 0;
}

6. #include <stdio.h>
int main()
{
int i -= 3;
while (i--)
{
int i = 100;
i--;
printf("%d ", i);
}
return 0;
}

7. #include "stdio.h"
int main()
{
int i = 1, j;
for ( ; ; );
{
if (i)
j = --i;
if (j < 10)
printf("C Programming", j++);
else
break;
}
return 0;
}

8. #include "stdio.h"
int main(){
int j = 0;
for ( ; j < 10) {
if (j < 10)
printf("C", j++);
else
continue;
printf(“Programming”);
}
return 0;
}
9. Write a C program to find sum of all natural numbers between 1 to n. n given as input by
user.
10. Write a C program that converts Celsius to Fahrenheit.
11. Write a C program to print the following pattern:
a. * b. * c. 1
** ** 23
*** *** 456
**** **** 7 8 9 10
(right half pyramid) (full pyramid) (Floyd’s Triangle)
12. Using Switch statement, write a program that displays the following menu for the food
items available to take order from the customer:
• B= Burger
• F= French Fries
• P= Pizza
• S= Sandwiches
The program inputs the type of food and quantity. It finally displays the total charges for
the order according to following criteria:
• Burger = Rs. 200
• French Fries= Rs. 50
• Pizza= Rs. 500
• Sandwiches= Rs. 15

You might also like