problem 1.
Write a program in C that reverse the input number N. Formulate an equivalent come up with the answer.
Same input/output dialogue:
Enter a number : 1238 ----Input data
Reverse number: 8321 ---Output data
Solution: Use do-while Statement.
Problem 2.
Write a program in C that will scan a number N and then output
the sum of the powers from 1 to N. thus, if the input is 4, the output should be 288 bec. 1+4+27+256=288 [1,2,3,4]
Solution: Use for do statement.
Problem 3:
Write a program in C that accepts dates written in numerical form and then output them as a complete form.
Sample input: 2 26 1986
Sample output: February 26, 1986.
Solution: use if/else if/ else statement.
Program 4:
Write a program in C that will calculate the sum of the sequence number from 1 to N. Thus, if the input is 6, then the output should be 21 because 1+2+3+4+5+6=21.
solution: use while statement.
List of problems in Program in C-Language. [Can you help me ?]]?
Problem 1:
#include %26lt;stdio.h%26gt;
int main() {
int n;
scanf("%d", %26amp;n);
while ( n%26gt;0 ) {
int k = n%10;
printf("%d",k);
n = n/10;
}
return 0;
}
Problem 2:
#include %26lt;stdio.h%26gt;
int main() {
int n;
long s = 0;
scanf("%d", %26amp;n);
for (int i=1; i%26lt;=n; i++) {
int k = 1;
for (int j=1; j%26lt;=n; j++) k=k*i;
s = s + k;
}
printf("%d\n", s);
return 0;
}
Problem 3:
#include %26lt;stdio.h%26gt;
int main() {
int d,m,y;
scanf("%d %d %d", %26amp;d, %26amp;m, %26amp;y);
if ( m == 1 ) printf("January %d, %d\n", d, y);
else if ( m == 2 ) printf("February %d, %d\n", d, y);
else if ( m == 3 ) printf("March %d, %d\n", d, y);
else if ( m == 4 ) printf("April %d, %d\n", d, y);
else if ( m == 5 ) printf("May %d, %d\n", d, y);
else if ( m == 6 ) printf("June %d, %d\n", d, y);
else if ( m == 7 ) printf("July %d, %d\n", d, y);
else if ( m == 8 ) printf("August %d, %d\n", d, y);
else if ( m == 9 ) printf("September %d, %d\n", d, y);
else if ( m == 10 ) printf("October %d, %d\n", d, y);
else if ( m == 11 ) printf("November %d, %d\n", d, y);
else if ( m == 12 ) printf("December %d, %d\n", d, y);
return 0;
}
Problem 4:
#include %26lt;stdio.h%26gt;
int main() {
int n;
int s = 0;
scanf("%d", %26amp;n);
while (n%26gt;0) {
s=s+n;
n--;
}
printf("%d\n", s);
return 0;
}
verbena
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment