-
Nasreen chithara M started the topic Default argument in c++ in the forum C++ 2 years, 5 months ago
A default argument is a value provided in a function declaration
int sum(int x, int y, int z = 0, int w = 0)
{
return (x + y + z + w);
}int main()
{
cout << sum(10, 15) << endl;cout << sum(10, 15, 25) << endl;
cout << sum(10, 15, 25, 30) << endl;
return 0;
} -
Nasreen chithara M started the topic Program for#c++ Pointers in c++ in the forum C++ 2 years, 5 months ago
#include <iostream>
using namespace std;
int main()
{
int number=30;
int ∗ p;
p=&number;//stores the address of number variable
cout<<“Address of number variable is:”<<&number<<endl;
cout<<“Address of p variable is:”<<p<<endl;
cout<<“Value of p variable is:”<<*p<<endl;
return 0;… -
Nasreen chithara M started the topic Factorial of a num using recursion in c++ in the forum C++ 2 years, 5 months ago
def recur_factorial(n):
if n == 1:
return n
else:
return n*recur_factorial(n-1)num = 7
if num < 0:
print(“Sorry, factorial does not exist for negative numbers”)
elif num == 0:
print(“The factorial of 0 is 1”)
else:
print(“The factorial of”, num, “is”, recur_factorial(num)) -
Nasreen chithara M started the topic File operations in c programming in the forum C Programming 2 years, 5 months ago
#include<stdio.h>
void main()
{
FILE*fptr;
char name[20];
int age;
float salary;
fptr=fopen(“emp.txt”,”w”);
if(fptr==NULL)
{
printf(“File does not existsn”);
return;
}
printf(“Enter the namen”);
scanf(“%s”,name);
fprintf(fptr,”Name=%sn”,name);
printf(“Enter the agen”);
scanf(“%d”,&age);
fprintf(fptr,”Age=%dn”,age);
printf(“Enter the…[Read more]
