You are on page 1of 2

#include <stdio.

h>
int main()
{
/* printf function displays the content that is
* passed between the double quotes.
*/
printf("Hello World");
return 0;
}

#include <stdio.h>

void main()
{
int num;

printf("Enter a number: \n");


scanf("%d", &num);
if (num > 0)
printf("%d is a positive number \n", num);
else if (num < 0)
printf("%d is a negative number \n", num);
else
printf("0 is neither positive nor negative");
}

#include <stdio.h>

int main() {

double num1, num2, num3;

printf("Enter first number: ");


scanf("%lf", &num1);
printf("Enter second number: ");
scanf("%lf", &num2);
printf("Enter third number: ");
scanf("%lf", &num3);

// if num1 is greater than num2 & num3, num1 is the largest


if (num1 >= num2 && num1 >= num3)
printf("%lf is the largest number.", num1);

// if num2 is greater than num1 & num3, num2 is the largest


if (num2 >= num1 && num2 >= num3)
printf("%lf is the largest number.", num2);

// if num3 is greater than num1 & num2, num3 is the largest


if (num3 >= num1 && num3 >= num2)
printf("%lf is the largest number.", num3);

return 0;
}

#include<stdio.h>
int main()
{
int count, first_term = 0, second_term = 1, next_term, i;

//Ask user to input number of terms


printf("Enter the number of terms:\n");
scanf("%d",&count);

printf("First %d terms of Fibonacci series:\n",count);


for ( i = 0 ; i < count ; i++ )
{
if ( i <= 1 )
next_term = i;
else
{
next_term = first_term + second_term;
first_term = second_term;
second_term = next_term;
}
printf("%d\n",next_term);
}

return 0;
}

You might also like