Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C program Prompt the user to enter three integers, one at a time and read the in

ID: 3682514 • Letter: C

Question

C program Prompt the user to enter three integers, one at a time and read the integers. Perform the calculation int1* int2 - int3 and output the results For instance, if the input is 3, 4 and 5, your program should output: 3 times 4 minus 5 is 7. Output each of the following using a single output statement for each problem. Print the message ""This is a C program" on one line. Print the message "This is a C program" on two lines so that the first line ends with is. Print the message "This is a C program" with each word on a separated line. Print the message "This is a C program'' with each word separated by tabs. Print the following pattern: Prompt and read from the user a five-digit integer. Output the digits of the integer separated from one another by three spaces each. For example, if the use types in 12345 then the program should output: The input number separated into its individual digits is 1 2 3 4 5.

Explanation / Answer

Program 1:
#include <stdio.h>
#include <stdlib.h>

int main()
{
int int1,int2,int3;
printf("Enter three values:");
scanf("%d%d%d",&int1,&int2,&int3);
printf("%d times %d minus %d is %d",int1,int2,int3,(int1*int2-int3));
return 0;
}

OUTPUT:

Enter three values:3
4
5

3 times 4 minus 5 is 7
Process returned 0 (0x0) execution time : 9.828 s
Press any key to continue.

Program 2:
#include <stdio.h>
#include <stdlib.h>

int main()
{

int i,j;
printf("This is C program ");
printf("This is C program ");
printf("This is C program ");
printf("This is C program ");

for(i=5; i>=1; i--)
{
for(j=1; j<=i; j++)
{
printf("*");
}
printf(" ");
}

return 0;
}

OUTPUT:
This is C program
This is
C program
This
is
C
program
This is C program
*****
****
***
**
*

Process returned 0 (0x0) execution time : 0.047 s
Press any key to continue.

Program 3:

#include <stdio.h>
#include <stdlib.h>

int main()
{
int n,i,j,c=1,r;
printf("Enter the number :");
scanf("%d",&n);
for(i=5; i>=1; i--)
{
c=1;
for(j=1; j<i; j++)
{
c=c*10;

}
r=n/c;

printf("%d ",r);
n=n%c;
}
return 0;
}


OUTPUT:
Enter the number :12345
1 2 3 4 5
Process returned 0 (0x0) execution time : 3.835 s
Press any key to continue.