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 |
void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(ā%dā,k); }
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }
how to return a multiple value from a function?
main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }
void main() { int i=i++,j=j++,k=k++; printf(ā%d%d%dā,i,j,k); }
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
write a program to count the number the same (letter/character foreg: 's') in a given sentence.
main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }
could you please send the program code for multiplying sparse matrix in c????