/*
Program to read two numbers and a range and print the series (Sum of previous two numbers) of given range.
*/
#include<stdio.h>
void main()
{
int range;
int fs,sec,count=2,temp;
printf("Enter the Fiirst and seconfd number:\n");
scanf("%d%d",&fs,&sec);
printf("Enter the Range:\n");
scanf("%d",&range);
if(fs<sec)
{
printf("%d\t%d\t",fs,sec);
while(count<range)
{
temp=fs+sec;
printf("%d\t",temp);
fs=sec;
sec=temp;
count++;
}
printf("\n");
}
else
{
printf("Invalid Input\n");
}
}
/*
Say my Input is 2 and 3 for numbers and range is 5
the output should be as follow
2 3 5 8 13
*/
Program to read two numbers and a range and print the series (Sum of previous two numbers) of given range.
*/
#include<stdio.h>
void main()
{
int range;
int fs,sec,count=2,temp;
printf("Enter the Fiirst and seconfd number:\n");
scanf("%d%d",&fs,&sec);
printf("Enter the Range:\n");
scanf("%d",&range);
if(fs<sec)
{
printf("%d\t%d\t",fs,sec);
while(count<range)
{
temp=fs+sec;
printf("%d\t",temp);
fs=sec;
sec=temp;
count++;
}
printf("\n");
}
else
{
printf("Invalid Input\n");
}
}
/*
Say my Input is 2 and 3 for numbers and range is 5
the output should be as follow
2 3 5 8 13
*/
No comments:
Post a Comment