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() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
why java is platform independent?
Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)
3 Answers Disney, Google, ZS Associates,
How to return multiple values from a function?
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }
x=2 y=3 z=2 x++ + y++; printf("%d%d" x,y);
Code for 1>"ascii to string" 2>"string to ascii"
1 Answers Aricent, Global Logic,
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }