Fundamentals of Computer Programming - Old Questions

Question Answer Details

9. List any five names of graphics function. Write a program to read line of text then count no. of vowels, No. of digits and no. of spaces. [2+4]

6 marks
Asked in 2070

Answer

AI Generated Answer

AI is thinking...

Official Answer

Some names of graphics function:

initgraph(): it is one of the function that is used to initialize the computer in graphics mode. Its syntax is as

        initgraph(&gdriver, &gmode, "graphics driver path");

closegraph(): It is the graphical function that is used to close the graphics mode initialized by the initgraph() function.

setcolor(color): It is a function that is used to set the color of the drawing object with given color. The color is indicated by the integer from 0 to 15 ( 16 color)

lineto(x, y): draws the line from current position to (x,y) position.

clrscr(): It is used to clear the screen and locates the curser at the beginning of the screen.

cputs(string): it writes a string given to function to the user defined window screen.

putch(char) : it writes a character given to function to the user defined area of window.

line(a, b, c, d): draws line from (a,b) to (c,d).

circle(x, y, r): prints circle with center (x,y) and radius r.

rectangle(a, b, c, d): prints rectangle where (a,b) is upper left coordinate and (c,d) is lower right co-ordinates of rectangle.


Program to read line of text then count no. of vowels, No. of digits and no. of spaces:

#include <stdio.h>

void main()

{

    char str[200];

    int i, vowels=0, digits=0, spaces=0;

    printf("Enter a string\\n");

    gets(str);

    for(i=0;str[i]!='\\0';i++)

    {

        if(str[i]=='a' || str[i]=='e' || str[i]=='i' ||str[i]=='o' || str[i]=='u' || str[i]=='A' ||str[i]=='E' || str[i]=='I' || str[i]=='O' ||str[i]=='U')

        {

            vowels++;

        }

       

        else if(str[i]>='0' && str[i]<='9')

        {

            digits++;

        }

        else if (str[i]==' ')

        {

            spaces++;

        }

    }

    printf("\\nVowels = %d",vowels);

    printf("\\nDigits = %d",digits);

    printf("\\nWhite spaces = %d",spaces);

}