Some questions related to C language Download All Code 1. Write a program to print your name on the screen ? #include<stdio.h> int ma...
Some questions related to C language
1. Write a program to print your name on the screen ?
#include<stdio.h>
int main(){
printf("Suresh Yadav"); return 0;
} |
|
3. WAP to display name and address from user ?
|
4. WAP to convert kilometer into meter ?
|
5. WAP to print multiplication table ?
|
6. WAP using If else statement ?
|
7. WAP to calculate percentage ?
|
8. Input total marks and obtained marks from user then find his/her percentage and print the information if s/he has obtained percentage :
Above 90 - Outstanding
80-90 - Distinction
60 - 80 - First Division
45-60 - Second Division
32-45 - Third Division
Below 32 - Better for next time
|
9. WAP to find area of rectangle, circle, cube and sphere ?
|
|
|
|
|
|
|
|
|
|
|
|
For eg: 1 - Sunday
2 - Monday
……..
……..
7 - Saturday
|
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
|
23. 1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
|
24. 5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
|
25. 1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
|
26. 1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
|
27. *
* *
* * *
* * * *
|
28. WAP to add 10 numbers from user using array ?
|
|
|
|
|
|
|
|
|
|
|
|
|
#include<stdio.h> #include<conio.h> main() //main start { int year,month,day,result=-1,Day=5,dividedyear,twodigit,yearcode,exit1; //converting B.S into A.D do //loop start { printf("Enter any date in A.D to findout the day:\n"); printf("Enter year:"); scanf("%d",&year); printf("Enter month:"); scanf("%d",&month); printf("Enter day:"); scanf("%d",&day); twodigit=year%100; dividedyear=twodigit/4; if(month<=12 && day<=32) //if statement start { if(year<=3000 && year>=2000) { yearcode=(-1); } else if(year<=1999 && year>=1900) { yearcode=(0); } else if(year<=1899 && year>=1800) { yearcode=(+2); } else if(year<=1799 && year>=1700) { yearcode=(+4); } else { printf("ERROR.......\n"); } if(year>=1700 && year<=3000) { switch(month) { case 1: if(year%4==0 || year%400==0) { result= (day%7)+0+(year%100)+(yearcode)+(dividedyear); } else { result= (day%7)+1+(year%100)+(yearcode)+(dividedyear); } break; case 2: if(day<=28 || day<=29) { if(year%4==0 || year%400==0) { result=(day%7)+3+(year%100)+(yearcode)+dividedyear; } else { result=(day%7)+4+(year%100)+(yearcode)+dividedyear; } } else { printf("ERROR........INVALID DATE\n\n"); } break; case 3:result=(day%7)+4+(year%100)+(yearcode)+dividedyear; break; case 4:result=(day%7)+0+(year%100)+(yearcode)+dividedyear; break; case 5:result=(day%7)+2+(year%100)+(yearcode)+dividedyear; break; case 6:result=(day%7)+5+(year%100)+(yearcode)+dividedyear; break; case 7:result=(day%7)+0+(year%100)+(yearcode)+dividedyear; break; case 8:result=(day%7)+3+(year%100)+(yearcode)+dividedyear; break; case 9:result=(day%7)+6+(year%100)+(yearcode)+dividedyear; break; case 10:result=(day%7)+1+(year%100)+(yearcode)+dividedyear; break; case 11:result=(day%7)+4+(year%100)+(yearcode)+dividedyear; break; case 12:result=(day%7)+6+(year%100)+(yearcode)+dividedyear; break; } } else { printf("Sorry out of range.\n\n"); } if(result>=7) { Day=result%7; } else { Day=result; } switch(Day) //switch statement start { case 1:printf("The day is Sunday.\n\n"); break; case 2:printf("The day is Monday.\n\n"); break; case 3:printf("The day is Tuesday.\n\n"); break; case 4:printf("The day is Wednesday.\n\n"); break; case 5:printf("The day is Thursday.\n\n"); break; case 6:printf("The day is Friday.\n\n"); break; case 0:printf("The day is Saturday.\n\n"); break; case -1:printf(" "); break; //switch statement close } //if statement close } else { printf("ERROR.....\n\n"); } getch(); system("cls"); //loop close } while(year!=0); //main close return 0; } |
-----------------------------------------------------------------------------------------------------------------------------
The End
-----------------------------------------------------------------------------------------------------------------------------
This question is so imp so i will try to do this
ReplyDeleteThis comment has been removed by the author.
ReplyDelete