C Program to print numbers from 1 to N without using semicolon

Write a program to print numbers from 1 to N without using a semicolon.

 Example:

Input:  N = 8
Output: 1 2 3 4 5 6 7 8 

Approach

C

#include <stdio.h>
#define N 8

int main(int numchar *argv[])
{
    while (num <= N && printf("%d "num) && num)
    {
        num++;
    }
}


No comments:

Post a Comment