Write a complete program that consists of a function that
can receive two numbers
from a user (M and N) as a parameter. Then print all the
numbers between the two
numbers including the number itself. If the value of M is
smaller than N, print the
numbers in ascending flow. If the value of M is bigger than
N, print the numbers in
descending flow. may i know how the coding look like?
Answers were Sorted based on User's Feedback
#include<stdio.h>
void printnum(int,int);
void main()
{
int m,n;
printf("\nEnter the numbers :");
scanf("%d%d",&m,&n);
printnum(m,n);
}
printnum(int m,int n)
{
int i;
if(m>n)
for(i=m;i>=n;i--)
printf(" %d",i);
else if(m<n)
for(i=m;i<=n;i++)
printf(" %d",i);
else //if m and n are equal
printf("%d",m);
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / jaycn67
If M = 3, N = 7;
The output is: 3 4 5 6 7
If M = 7, N = 3;
The output is: 7 6 5 4 3.
| Is This Answer Correct ? | 0 Yes | 1 No |
main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }
How can you relate the function with the structure? Explain with an appropriate example.
main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }
Write a C program to add two numbers before the main function is called.
program to find magic aquare using array
what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }
How we will connect multiple client ? (without using fork,thread)
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql