Write a program to print the series 1-2 3-4…n . n is given | CODE WITH SHARAD

Write a program to print the series 1-2 3-4...n . n is given

Written by Sharad Raj on 13th of March, 2018

BASIC PROGRAMS   C LANGUAGE PROGRAMS

PROGRAM CODE

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,a;

clrscr();

printf(“Enter the value of n : ”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

if(i%2==0)

printf(“ -%d ”,i);

else

printf(“ %d ”,i);

}

getch();

}


Comments


Contact